// To parse this JSON data, do
//
//     final myCollectionModel = myCollectionModelFromJson(jsonString);

import 'dart:convert';

MyCollectionModel myCollectionModelFromJson(String str) => MyCollectionModel.fromJson(json.decode(str));

String myCollectionModelToJson(MyCollectionModel data) => json.encode(data.toJson());

class MyCollectionModel {
  List<CollectionRecord>? records;
  int? total;
  int size;
  int current;
  List<dynamic>? orders;
  bool? searchCount;
  int pages;

  MyCollectionModel({
    this.records,
    this.total,
    this.size = 10,
    this.current = 1,
    this.orders,
    this.searchCount,
    this.pages = 1,
  });

  factory MyCollectionModel.fromJson(Map<String, dynamic> json) => MyCollectionModel(
    records: json["records"] == null ? [] : List<CollectionRecord>.from(json["records"]!.map((x) => CollectionRecord.fromJson(x))),
    total: json["total"],
    size: json["size"],
    current: json["current"],
    orders: json["orders"] == null ? [] : List<dynamic>.from(json["orders"]!.map((x) => x)),
    searchCount: json["searchCount"],
    pages: json["pages"],
  );

  Map<String, dynamic> toJson() => {
    "records": records == null ? [] : List<CollectionRecord>.from(records!.map((x) => x.toJson())),
    "total": total,
    "size": size,
    "current": current,
    "orders": orders == null ? [] : List<CollectionRecord>.from(orders!.map((x) => x)),
    "searchCount": searchCount,
    "pages": pages,
  };
}

class CollectionRecord {
  int? id;
  int? roomId;
  String content;
  String? voiceUrl;
  int? sendType;
  DateTime? createTime;
  int isCollect;
  int isLike;

  CollectionRecord({
    this.id,
    this.roomId,
    this.content = '',
    this.voiceUrl,
    this.sendType,
    this.createTime,
    this.isCollect = 1,
    this.isLike = 0,
  });

  factory CollectionRecord.fromJson(Map<String, dynamic> json) => CollectionRecord(
    id: json["id"],
    roomId: json["roomId"],
    content: json["content"],
    voiceUrl: json["voiceUrl"],
    sendType: json["sendType"],
    createTime: json["createTime"] == null ? null : DateTime.parse(json["createTime"]),
    isCollect: json["isCollect"] ?? 0,
    isLike: json["isLike"] ?? 0,
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "roomId": roomId,
    "content": content,
    "voiceUrl": voiceUrl,
    "sendType": sendType,
    "createTime": createTime?.toIso8601String(),
    "isCollect": isCollect,
    "isLike": isLike,
  };
}
